//package com.fingard.dsp.bank.directbank.ccb04;
//
//import com.fingard.constant.Format;
//import com.fingard.dsp.bank.directbank.bankInterface.IElecBillQuery;
//import com.fingard.dsp.bank.reqrespobj.elecbillquery.*;
//import com.fingard.dsp.bank.reqrespobj.elecbillquery.detail.RetAtsB001OperBillQryDetail;
//import com.fingard.dsp.bank.reqrespobj.elecbillquery.detail.RetAtsB005BillBackQryDetail;
//import com.fingard.dsp.bank.reqrespobj.elecbillquery.detail.RetAtsB006BillStateQryDetail;
//import com.fingard.dsp.bank.reqrespobj.elecbillquery.detail.RetAtsB007BillKzsrQryDetail;
//import com.fingard.text.StringHelper;
//import com.fingard.util.DateHelper;
//import com.fingard.xml.XmlTextReader;
//import com.fingard.xml.XmlTextWriter;
//
//import java.io.File;
//import java.util.ArrayList;
//import java.util.Calendar;
//import java.util.List;
//
///**
// * @author Parker on 2019-12-31.
// * @version 1.0
// */
//public class CCB04ElecBill extends CCB04Base implements IElecBillQuery {
//    //可操作票据查询
//    @Override
//    public RetAtsB001OperBillQry D_OperBill_Query_Req(ReqB001OperBillQry query) throws Exception {
//        RetAtsB001OperBillQry retAts = new RetAtsB001OperBillQry(query.reqHeader);
//        retAts.respCode = "0";
//        while (query.readRecord()) {
//            try {
//                if ("1".equals(query.detail.queryType)) {
//                    //查询申请类的票据
//                    queryBillByApply(query, retAts);
//                } else if ("2".equals(query.detail.queryType)) {
//                    //查询签收类的票据
//                    queryBillByP1ECDS256(query, retAts);//待签收票据查询
//                } else {
//                    //查询可撤销的票据
//                    queryBillByCancel(query, retAts);
//                }
//            } catch (Exception ex) {
//                ex.printStackTrace();
//                retAts = new RetAtsB001OperBillQry(query.reqHeader);
//                retAts.writeBefore();
//                retAts.respCode = "-1";
//                retAts.respInfo = ex.getMessage();
//            }
//        }
//        retAts.writeEnd();
//        return retAts;
//    }
//
//    private void queryBillByCancel(ReqB001OperBillQry query, RetAtsB001OperBillQry retAts) throws Exception {
//        //待撤销票据查询
//        if ("1".equals(query.detail.busiType)) {
//            queryBillByP1ECDS255(query, retAts, "0002");
//            queryBillByP1ECDS255(query, retAts, "0003");
//        } else {
//            switch (Integer.valueOf(query.detail.busiType)) {
//                case 2:
//                    queryBillByP1ECDS254(query, retAts, "0001", "020001");
//                    break;//承兑撤回
//                case 3:
//                    queryBillByP1ECDS254(query, retAts, "0002", "030001");
//                    break;//收票撤回
//                case 4:
//                    queryBillByP1ECDS254(query, retAts, "0004", "100001");
//                    break;//背书撤回
//                case 5:
//                    queryBillByP1ECDS254(query, retAts, "0006", "180001");
//                    break;//质押撤回
//                case 6:
//                    queryBillByP1ECDS254(query, retAts, "0007", "190001");
//                    break;//质押解除撤回
//                case 10:
//                    queryBillByP1ECDS254(query, retAts, "0005", "110101");
//                    queryBillByP1ECDS254(query, retAts, "0005", "110201");
//                    break;//贴现撤回
//                case 12:
//                    if ("1".equals(query.detail.overdueFlag)) {
//                        queryBillByP1ECDS254(query, retAts, "0008", "200001");
//                    } else {
//                        queryBillByP1ECDS254(query, retAts, "0008", "210001");//逾期提示付款待签收
//                    }
//                    break;//提示付款撤回
//                case 13:
//                    if ("1".equals(query.detail.recourseType)) {
//                        queryBillByP1ECDS254(query, retAts, "0009", "220707");
//                    } else {
//                        queryBillByP1ECDS254(query, retAts, "0009", "220607");//拒付追索待清偿
//                    }
//                    break;//追索撤回
//                case 14:
//                    queryBillByP1ECDS254(query, retAts, "0010", "230601");
//                    queryBillByP1ECDS254(query, retAts, "0010", "230701");
//                    break;//非拒付追索同意清偿待签收
//                default:
//                    throw new Exception("未知的撤回业务类型：" + query.detail.busiType);
//            }
//        }
//    }
//
//    //应答查询
//    private void queryBillByP1ECDS256(ReqB001OperBillQry query, RetAtsB001OperBillQry retAts) throws Exception {
//        getBnkToken();
//        if (StringHelper.hasAnyChar(bankFront.token)) {
//            if (new File(String.format("%1$s%2$s_BnkPubKey.txt", strtmpFile, bankFront.org)).exists()) {
//                if (!"".equals(bankFront.loginFlag) && !"false".equals(bankFront.loginFlag)) {
//                    txCode = "P1ECDS256";
//                    reqSeqID = getQryTransID();
//                    String busiType;
//                    if ("2".equals(query.detail.queryType)) {
//                        switch (Integer.valueOf(query.detail.busiType)) {
//                            case 2:
//                                busiType = "0005";
//                                break;//承兑代签收
//                            case 5:
//                                busiType = "0007";
//                                break;//质押
//                            case 6:
//                                busiType = "0006";
//                                break;//质押解除
//                            case 12:
//                                busiType = "0008";
//                                break;//提示付款应答
//                            case 11://回购式贴现
//                            case 14:
//                                busiType = "0001";
//                                break;//其他
//                            case 3:
//                                busiType = "0003";
//                                break;//收票待签收
//                            case 4:
//                                busiType = "0004";
//                                break;//背书待签收
//                            default:
//                                throw new Exception("业务类型未知：" + query.detail.busiType);
//                        }
//                    } else {
//                        busiType = "0002";
//                    }
//                    XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//                    //写入报文头部信息
//                    writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//                    xmlWriterWithoutCDATA.writeStartElement("request");
//                    writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                    xmlWriterWithoutCDATA.writeElementString("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票出票人组织机构代码
//                    if ("1".equals(query.detail.billType)) {
//                        xmlWriterWithoutCDATA.writeElementString("BkType1", "AC01");//AC01银承
//                    } else {
//                        xmlWriterWithoutCDATA.writeElementString("BkType1", "AC02");//只能填写 AC02商承
//                    }
//                    xmlWriterWithoutCDATA.writeElementString("Bk8Date1", "");//原电票交易日期
//                    xmlWriterWithoutCDATA.writeElementString("BkType2", busiType);//应答类型
//                    xmlWriterWithoutCDATA.writeElementString("BkOthBrchNo1", "");//承兑人
//                    xmlWriterWithoutCDATA.writeElementString("BkFlag1", "");//背书转让标示
//                    xmlWriterWithoutCDATA.writeElementString("BkFlag3", "");//到期期限
//                    xmlWriterWithoutCDATA.writeElementString("BkFlag2", "");//出票人与承兑人是否相同
//                    xmlWriterWithoutCDATA.writeElementString("BkListNo1", "");//下载任务编号
//                    xmlWriterWithoutCDATA.writeElementString("BkInstNo1", "");//原申请人组织代码
//                    xmlWriterWithoutCDATA.writeElementString("BkAcctNum", "1");//账号数量
//                    xmlWriterWithoutCDATA.writeStartElement("BkAcctQuery_GRP");
//                    xmlWriterWithoutCDATA.writeElementString("BkEcdQueryAcct", query.detail.actNum);//账号数量
//                    xmlWriterWithoutCDATA.writeEndElement();
//                    xmlWriterWithoutCDATA.writeEndDocument();
//                    int n = xmlWriterWithoutCDATA.toXmlString().length();
//                    xmlLength = decimalFormat.format(n);
//
//                    XmlTextWriter xmlWriter = new XmlTextWriter();
//                    writeCommonHeader(xmlWriter);
//                    xmlWriter.writeStartElement("request");
//                    writeElecBillComEntity(xmlWriter, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                    xmlWriter.writeElementCDATA("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票出票人组织机构代码
//                    if ("1".equals(query.detail.billType)) {
//                        xmlWriter.writeElementCDATA("BkType1", "AC01");//AC01银承
//                    } else {
//                        xmlWriter.writeElementCDATA("BkType1", "AC02");//只能填写 AC02商承
//                    }
//                    xmlWriter.writeElementCDATA("Bk8Date1", "");//原电票交易日期
//                    xmlWriter.writeElementCDATA("BkType2", busiType);//应答类型
//                    xmlWriter.writeElementCDATA("BkOthBrchNo1", "");//承兑人
//                    xmlWriter.writeElementCDATA("BkFlag1", "");//背书转让标示
//                    xmlWriter.writeElementCDATA("BkFlag3", "");//到期期限
//                    xmlWriter.writeElementCDATA("BkFlag2", "");//出票人与承兑人是否相同
//                    xmlWriter.writeElementCDATA("BkListNo1", "");//下载任务编号
//                    xmlWriter.writeElementCDATA("BkInstNo1", "");//原申请人组织代码
//                    xmlWriter.writeElementCDATA("BkAcctNum", "1");//账号数量
//                    xmlWriter.writeStartElement("BkAcctQuery_GRP");
//                    xmlWriter.writeElementCDATA("BkEcdQueryAcct", query.detail.actNum);//账号数量
//                    xmlWriter.writeEndElement();
//                    xmlWriter.writeEndDocument();
//
//                    String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
//
//                    if (tmpStrRet[0].length() == 0) {
//                        StringBuilder msg = new StringBuilder();
//                        XmlTextReader tmpBkReader = getBankInfo(tmpStrRet[1], msg);
//                        if (tmpBkReader != null) {
//                            String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                            String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                            String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                            if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                                retAts.writeBefore();
//                                while (tmpBkReader.read("/Transaction/Transaction_Body/response/BkDqs_GRP")) {
//                                    String signAct = tmpBkReader.readedXElement.getSingleText("BkAcctNo7");
//                                    if (StringHelper.hasAnyChar(signAct) && signAct.equals(query.detail.actNum)) {
////                                          BkType2 应答类型 Char(4) F
////                                          0:收款人应答
////                                          1:出票保证人应答
////                                          2:承兑保证人应答
////                                          3:背书保证人应答（1，2，3目前根据人行接口无法区分具体何种保证，返回网银统一为1）
////                                          4:承兑应答
////                                          5:背书转让应答
////                                          6:付款应答
////                                          7：追索应答（被追索人收到追索人发起的追索申请后，可以发起同意清偿或不予处理）
////                                          8:同意清偿应答（追索人收到被追索人发起的清偿申请后，做签收或驳回）
////                                          9.质押应答（只有商承）
////                                          10:质押解除应答
////                                          11:贴现赎回应答
//                                        String bktype2 = tmpBkReader.readedXElement.getSingleText("BkType2");
//                                        if (!checkBkType(Integer.parseInt(query.detail.busiType), query.detail.queryType, bktype2, query.detail.billType)) {
//                                            continue;
//                                        }
//                                        RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
////                                          13 BkListNo1 电子票据号码 varChar(30) F 　
//                                        detail.billNo = tmpBkReader.readedXElement.getSingleText("BkListNo1");
//                                        //票据类型
//                                        detail.billType = "1".equals(query.detail.billType) ? "EM001" : "EM002";
//                                        //27 Bk8Date1 出票日期 Char(8) F 　
//                                        detail.issDate = DateHelper.convertD8toD10(tmpBkReader.readedXElement.getSingleText("Bk8Date1"));
//                                        //29 Bk8Date2 汇票到期日 Char(8) F 　
//                                        detail.dueDate = DateHelper.convertD8toD10(tmpBkReader.readedXElement.getSingleText("Bk8Date2"));
////                                          26 BkAmt1 出票金额 Decimal(18,2) F 　
//                                        detail.billAmt = tmpBkReader.readedXElement.getSingleText("BkAmt1");
////                                          28 BkType3 不得转让标识 Char(4) F 票据的属性
//                                        String transFlag = tmpBkReader.readedXElement.getSingleText("BkType3");
//                                        if ("EM00".equals(transFlag)) {
//                                            detail.transFlag = "1";
//                                        } else {
//                                            detail.transFlag = "0";
//                                        }
//                                        //承兑无条件支付委托 1-无条件支付 0-非条件支付
//                                        detail.mustPay = "";
//                                        //14 Bk60Name1 出票人名称 varChar(120) F 　
//                                        detail.drawName = tmpBkReader.readedXElement.getSingleText("Bk60Name1");
//                                        //16 BkBrchNo1 出票人开户行 varChar(12) F 　
//                                        detail.drawBnkCode = tmpBkReader.readedXElement.getSingleText("BkBrchNo1");
//                                        //15 BkAcctNo1 出票人账号 varChar(32) F 　
//                                        detail.drawAct = tmpBkReader.readedXElement.getSingleText("BkAcctNo1");
//                                        //20 Bk60Name3 承兑人名称 varChar(120) F 　
//                                        detail.accpName = tmpBkReader.readedXElement.getSingleText("Bk60Name3");
//                                        //21 BkBrchNo3 承兑人开户行 varChar(12) F 　
//                                        detail.accpBnkCode = tmpBkReader.readedXElement.getSingleText("BkBrchNo3");
//                                        //17 Bk60Name2 收款人名称 varChar(120) F 　
//                                        detail.payeeName = tmpBkReader.readedXElement.getSingleText("Bk60Name2");
//                                        //18 BkAcctNo2 收款人账号 varChar(32) F 　
//                                        detail.payeeAct = tmpBkReader.readedXElement.getSingleText("BkAcctNo2");
//                                        //19 BkBrchNo2 收款人开户行 varChar(12) F 　
//                                        detail.payeeBnkCode = tmpBkReader.readedXElement.getSingleText("BkBrchNo2");
//                                        //交易明细流水：原ECDS平台日期+原ECDS平台流水
//                                        detail.busiNo = tmpBkReader.readedXElement.getSingleText("BkOldPlatDate") + "_" + tmpBkReader.readedXElement.getSingleText("BkOldSeq");
//                                        //33 Bk60Name6 申请人名称 varChar(120) T 　
//                                        detail.applyName = tmpBkReader.readedXElement.getSingleText("Bk60Name6");
//                                        //34 BkAcctNo6 申请人账号 varChar(32) T 　
//                                        detail.applyAct = tmpBkReader.readedXElement.getSingleText("BkAcctNo6");
//                                        //35 BkBrchNo6 申请人开户行行号 varChar(12) T 　
//                                        detail.applyBnkCode = tmpBkReader.readedXElement.getSingleText("BkBrchNo6");
//                                        if ("0003".equals(busiType)) {
//                                            if (StringHelper.isNullOrEmpty(detail.applyAct)) {
//                                                detail.applyAct = detail.drawAct;
//                                            }
//                                            if (StringHelper.isNullOrEmpty(detail.applyName)) {
//                                                detail.applyName = detail.drawName;
//                                            }
//                                            if (StringHelper.isNullOrEmpty(detail.applyBnkCode)) {
//                                                detail.applyBnkCode = detail.drawBnkCode;
//                                            }
//                                        }
////                                          Bk60Name7 签收人名称 varChar(120) F 当应答类型为8时返回被追索人
//                                        detail.receName = tmpBkReader.readedXElement.getSingleText("Bk60Name7");
////                                          38 BkAcctNo7 签收人账号 varChar(32) F
//                                        detail.receAct = tmpBkReader.readedXElement.getSingleText("BkAcctNo7");
////                                          39 BkBrchNo7 签收人开户行行号 varChar(12) F
//                                        detail.receBnkCode = tmpBkReader.readedXElement.getSingleText("BkBrchNo7");
//                                        //36 BkDetail1 申请人备注 varChar(512) T 　
//                                        detail.memo = tmpBkReader.readedXElement.getSingleText("BkDetail1");
//                                        //逾期原因说明
//                                        detail.overDueRea = tmpBkReader.readedXElement.getSingleText("Bk60Name8");
//                                        if ("6".equals(bktype2)) {
//                                            if (StringHelper.hasAnyChar(detail.overDueRea)) {
//                                                detail.overDueFlag = "2";
//                                            } else {
//                                                detail.overDueFlag = "1";
//                                            }
//                                        }
//                                        //追索类型 1-拒付追索 2-非拒付追索
//                                        detail.recourseType = "";
//                                        //追索金额
//                                        String recoAmt = tmpBkReader.readedXElement.getSingleText("BkAmt2");
//                                        if (StringHelper.hasAnyChar(recoAmt)) {
//                                            detail.recourseAmt = recoAmt;
//                                        }
//                                        //30 BkFlag1 票据状态 Char(6) F 　
//                                        detail.billStatus = tmpBkReader.readedXElement.getSingleText("BkFlag1");
////                                          31 BkOldPlatDate 原ECDS平台日期 Char(8) F 　
////                                          32 BkOldSeq 原ECDS平台流水号 Int F 　
////                                          40 BkAmt2 清偿金额 Decimal(18,2) T 在应答类型为7,8时，必须返回
//                                        detail.recourseAmt = tmpBkReader.readedXElement.getSingleText("BkAmt2");
//                                        retAts.writeDetail(detail);
//                                    }
//                                }
//                            }else if("YBLECDA10000".equals(xln_resp_code)){
//                                retAts.respInfo = xln_status + xln_resp_code + xln_resp_desc;
//                                retAts.writeBefore();
//                            } else {
//                                retAts.respCode = "-1";
//                                retAts.respInfo = xln_status + xln_resp_code + xln_resp_desc;
//                                retAts.writeBefore();
//                            }
//                        } else {
//                            retAts.respCode = "-1";
//                            retAts.respInfo = msg.toString();
//                            retAts.writeBefore();
//                        }
//                    } else {
//                        retAts.respCode = "-1";
//                        retAts.respInfo = tmpStrRet[1];
//                        retAts.writeBefore();
//                    }
//                } else {
//                    retAts.respCode = "-1";
//                    retAts.respInfo = "签到失败";
//                    retAts.writeBefore();
//                }
//            } else {
//                retAts.respCode = "-1";
//                retAts.respInfo = "下载银行pub密钥失败";
//                retAts.writeBefore();
//            }
//        } else {
//            retAts.respCode = "-1";
//            retAts.respInfo = "下载银行3des密钥失败";
//            retAts.writeBefore();
//        }
//    }
//
//    //票据操作明细查询
//    @Override
//    public RetAtsB002BillTransQry D_B002_BillTrans_Query(ReqB002BillTransQry query) throws Exception {
//        return null;
//    }
//
//    //正面信息查询
//    @Override
//    public RetAtsB004BillFrontQry D_B004_BillFront_Query(ReqB004BillFrontQry query) throws Exception {
//        RetAtsB004BillFrontQry retAts = new RetAtsB004BillFrontQry(query.reqHeader);
//        retAts.writeStart();
//        try {
//            getBnkToken();
//            if (StringHelper.hasAnyChar(bankFront.token)) {
//                if (new File(String.format("%1$s%2$s_BnkPubKey.txt", strtmpFile, bankFront.org)).exists()) {
//                    if (!"".equals(bankFront.loginFlag) && !"false".equals(bankFront.loginFlag)) {
//                        while (query.readRecord()) {
//                            txCode = "P1ECDS278";
//                            reqSeqID = getQryTransID();
//                            XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//                            //写入报文头部信息
//                            writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//                            xmlWriterWithoutCDATA.writeStartElement("request");
//                            writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, query.reqHeader.transSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriterWithoutCDATA.writeElementString("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票出票人组织机构代码 TODO
//                            xmlWriterWithoutCDATA.writeElementString("BkNum1", "1");//输入信息总笔数
//                            xmlWriterWithoutCDATA.writeStartElement("Bkqqplhpcx_GRP");
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo1", query.detail.billNo);
//                            xmlWriterWithoutCDATA.writeEndDocument();
//                            int n = xmlWriterWithoutCDATA.toXmlString().length();
//                            xmlLength = decimalFormat.format(n);
//
//                            XmlTextWriter xmlWriter = new XmlTextWriter();
//                            writeCommonHeader(xmlWriter);
//                            xmlWriter.writeStartElement("request");
//                            writeElecBillComEntity(xmlWriter, query.reqHeader.transSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriter.writeElementCDATA("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//查询人组织机构代码 TODO
//                            xmlWriter.writeElementCDATA("BkNum1", "1");//输入信息总笔数
//                            xmlWriter.writeStartElement("Bkqqplhpcx_GRP");
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo1", query.detail.billNo);
//                            xmlWriter.writeEndDocument();
//
//                            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
//
//                            if (tmpStrRet[0].length() == 0) {
//                                StringBuilder msg = new StringBuilder();
//                                XmlTextReader tmpBkReader = getBankInfo(tmpStrRet[1], msg);
//                                if (tmpBkReader != null) {
//                                    String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                                    String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                                    String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                                    if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                                        if (tmpBkReader.read("/Transaction/Transaction_Body/response/Bkplhpcx1_GRP")) {
//                                            retAts.respCode = "0";
//                                            retAts.respInfo = "";
//                                            retAts.billNo = query.detail.billNo;//电子票据号码
//                                            String billType = tmpBkReader.readedXElement.getSingleText("BkType1");
//                                            if ("AC01".equals(billType)) {
//                                                retAts.billType = "1";
//                                            } else if ("AC02".equals(billType)) {
//                                                retAts.billType = "2";
//                                            }
//                                            //<Bk8Date1>出票日期<Bk8Date1>
//                                            retAts.issDate = DateHelper.convertD8toD10(tmpBkReader.readedXElement.getSingleText("Bk8Date1"));
//                                            //<Bk8Date2>到期日<Bk8Date2>
//                                            retAts.dueDate = DateHelper.convertD8toD10(tmpBkReader.readedXElement.getSingleText("Bk8Date2"));
//                                            //<BkAmt1>票据金额<BkAmt1>
//                                            retAts.billAmt = tmpBkReader.readedXElement.getSingleText("BkAmt1");
//                                            //                                <BkFlag2>转让标记<BkFlag2>
//                                            String transFlag = tmpBkReader.readedXElement.getSingleText("BkFlag2");
//                                            if ("EM00".equals(transFlag)) {
//                                                retAts.transFlag = "1";
//                                            } else if ("EM01".equals(transFlag)) {
//                                                retAts.transFlag = "0";
//                                            }
//                                            //出票人
//                                            retAts.drawName = tmpBkReader.readedXElement.getSingleText("Bk60Name1");
//                                            retAts.drawCode = tmpBkReader.readedXElement.getSingleText("BkInstNo");
//                                            retAts.drawAct = tmpBkReader.readedXElement.getSingleText("BkAcctNo1");
//                                            retAts.drawBnkCode = tmpBkReader.readedXElement.getSingleText("BkBrchNo1");
//
//                                            retAts.creditLv = tmpBkReader.readedXElement.getSingleText("BkLevel1");
//                                            retAts.gradeAgent = tmpBkReader.readedXElement.getSingleText("Bk60Name8");
//                                            retAts.gradeDueDate = DateHelper.convertD8toD10(tmpBkReader.readedXElement.getSingleText("Bk8Date3"));
//                                            retAts.drGuarName = tmpBkReader.readedXElement.getSingleText("BkDetail5");//出票保证人名称
//                                            retAts.drGuarAddr = tmpBkReader.readedXElement.getSingleText("BkDetail6");//出票保证人地址
//                                            retAts.drGuarDate = DateHelper.convertD8toD10(tmpBkReader.readedXElement.getSingleText("BkElctSgn1"));//出票保证日期
//                                            //承兑人
//                                            retAts.accpName = tmpBkReader.readedXElement.getSingleText("Bk60Name5");
//                                            retAts.accpAct = tmpBkReader.readedXElement.getSingleText("BkAcctNo5");
//                                            retAts.accpBnkName = tmpBkReader.readedXElement.getSingleText("Bk60Name6");
//                                            retAts.accpBnkCode = tmpBkReader.readedXElement.getSingleText("BkBrchNo4");
//                                            retAts.apGuarName = tmpBkReader.readedXElement.getSingleText("BkLoginTxCode");//承兑保证人名称
//                                            retAts.apGuarAddr = tmpBkReader.readedXElement.getSingleText("BkLoginSvc");//承兑保证人地址
//                                            retAts.apGuarDate = tmpBkReader.readedXElement.getSingleText("BkElctSgn2");//承兑保证日期
//                                            //收款人
//                                            retAts.payeeName = tmpBkReader.readedXElement.getSingleText("Bk60Name2");
//                                            retAts.payeeAct = tmpBkReader.readedXElement.getSingleText("BkAcctNo2");
//                                            retAts.payeeBnkCode = tmpBkReader.readedXElement.getSingleText("BkBrchNo3");
//                                            //票据状态
//                                            retAts.billState = tmpBkReader.readedXElement.getSingleText("BkFlag1");
//                                        } else {
//                                            throw new Exception("返回报文中没有票据明细标签！");
//                                        }
//                                    }else if("YBLECDA10000".equals(xln_resp_code)){
//                                        retAts.respInfo = xln_status + xln_resp_code + xln_resp_desc;
//                                    } else {
//                                        retAts.respCode = "-1";
//                                        retAts.respInfo = xln_status + xln_resp_code + xln_resp_desc;
//                                    }
//                                } else {
//                                    retAts.respCode = "-1";
//                                    retAts.respInfo = msg.toString();
//                                }
//                            } else {
//                                retAts.respCode = "-1";
//                                retAts.respInfo = tmpStrRet[1];
//                            }
//                        }
//                    } else {
//                        retAts.respCode = "-1";
//                        retAts.respInfo = "签到失败";
//                    }
//                } else {
//                    retAts.respCode = "-1";
//                    retAts.respInfo = "下载银行pub密钥失败";
//                }
//            } else {
//                retAts.respCode = "-1";
//                retAts.respInfo = "下载银行3des密钥失败";
//            }
//        } catch (Exception e) {
//            retAts.respCode = "-1";
//            retAts.respInfo = e.getMessage();
//            e.printStackTrace();
//        }
//        retAts.writeRetDetail();
//        retAts.writeEnd();
//        return retAts;
//    }
//
//    //票据背面信息查询
//    @Override
//    public RetAtsB005BillBackQry D_B005_BillBack_Query(ReqB005BillBackQry query) throws Exception {
//        RetAtsB005BillBackQry retAts = new RetAtsB005BillBackQry(query.reqHeader);
//        retAts.writeStart();
//        try {
//            getBnkToken();
//            if (StringHelper.hasAnyChar(bankFront.token)) {
//                if (new File(String.format("%1$s%2$s_BnkPubKey.txt", strtmpFile, bankFront.org)).exists()) {
//                    if (!"".equals(bankFront.loginFlag) && !"false".equals(bankFront.loginFlag)) {
//                        while (query.readRecord()) {
//                            txCode = "P1ECDS278";
//                            reqSeqID = getQryTransID();
//                            XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//                            //写入报文头部信息
//                            writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//                            xmlWriterWithoutCDATA.writeStartElement("request");
//                            writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriterWithoutCDATA.writeElementString("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票出票人组织机构代码 TODO
//                            xmlWriterWithoutCDATA.writeElementString("BkNum1", "1");//输入信息总笔数
//                            xmlWriterWithoutCDATA.writeStartElement("Bkqqplhpcx_GRP");
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo1", query.detail.billNo);
//                            xmlWriterWithoutCDATA.writeEndDocument();
//                            int n = xmlWriterWithoutCDATA.toXmlString().length();
//                            xmlLength = decimalFormat.format(n);
//
//                            XmlTextWriter xmlWriter = new XmlTextWriter();
//                            writeCommonHeader(xmlWriter);
//                            xmlWriter.writeStartElement("request");
//                            writeElecBillComEntity(xmlWriter, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriter.writeElementCDATA("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票出票人组织机构代码 TODO
//                            xmlWriter.writeElementCDATA("BkNum1", "1");//输入信息总笔数
//                            xmlWriter.writeStartElement("Bkqqplhpcx_GRP");
//                            xmlWriter.writeElementString("BkListNo1", query.detail.billNo);
//                            xmlWriter.writeEndDocument();
//
//                            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
//
//                            if (tmpStrRet[0].length() == 0) {
//                                StringBuilder msg = new StringBuilder();
//                                XmlTextReader tmpBkReader = getBankInfo(tmpStrRet[1], msg);
//                                if (tmpBkReader != null) {
//                                    String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                                    String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                                    String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                                    if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                                        String bknum = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/BkNum1");
//                                        if (!"1".equals(bknum)) {
//                                            throw new Exception("获取票据的背面信息失败");
//                                        }
//                                        while (tmpBkReader.read("/Transaction/Transaction_Body/response/Bkplhpcx1_GRP")) {
//                                            retAts.writeRespCode("0");
//                                            retAts.writeRespInfo("");
//                                            String resultArr = tmpBkReader.readedXElement.getSingleText("BkDetail7");
//                                            //交易类型|申请人名称|被申请人名称|不得转让标识|申请日期||@|$
//                                            String[] content = resultArr.split("@\\|\\$");
//                                            for (int i = 0; i < content.length; i++) {
//                                                String transFlag = "";
//                                                RetAtsB005BillBackQryDetail detail = new RetAtsB005BillBackQryDetail();
//                                                String[] rspArray = content[i].split("\\|", -1);
//                                                detail.respCode = "0";
//                                                detail.respInfo = "";
//                                                //电子票据号码
//                                                detail.billNo = query.detail.billNo;
//                                                //操作代码取值
//                                                /// 交易类型代码 2  承兑 3  收票 4  撤票 10  背书转让 11  贴现 12  回购式贴现赎回 13  转贴现 14  回购式转贴现赎回 15  再贴现 16  回购式再贴现赎回 25  央行卖出商业汇票 17  保证 18  质押 19  质押解除 20  提示付款 21  逾期提示付款 22  追索 23  追索同意清偿
//                                                detail.transCode = getTransCode(rspArray[0].trim());
////                                    00转让背书
////                                    03买断式贴现背书
////                                    05回购式贴现赎回背书
////                                    06买断式转贴现背书
////                                    08回购式转贴现赎回背书
////                                    09买断式再贴现背书
////                                    11回购式再贴现赎回背书
////                                    12央行卖出商业汇票
////                                    类型|背书人名称|被背书人名称|不得转让标记|背书日期| @|$
//                                                if ("00".equals(rspArray[0].trim()) || "03".equals(rspArray[0].trim()) || "05".equals(rspArray[0].trim())
//                                                        || "06".equals(rspArray[0].trim()) || "08".equals(rspArray[0].trim()) || "09".equals(rspArray[0].trim())
//                                                        || "11".equals(rspArray[0].trim()) || "12".equals(rspArray[0].trim())) {
//                                                    //申请人
//                                                    detail.applyName = rspArray[1].trim();
//                                                    //接收人
//                                                    detail.receName = rspArray[2].trim();
//                                                    //申请日期
//                                                    detail.applyDate = DateHelper.convertD8toD10(rspArray[4].trim());
//                                                    if ("EM00".equals(rspArray[3].trim())) {
//                                                        transFlag = "1";
//                                                    } else if ("EM01".equals(rspArray[3].trim())) {
//                                                        transFlag = "0";
//                                                    }
//                                                    detail.transFlag = transFlag;
//                                                }
////                                    01保证
////                                    类型|被保证人名称|保证人名称|保证人地址|保证日期| @|$
//                                                else if ("01".equals(rspArray[0].trim())) {
//                                                    //申请人
//                                                    detail.applyName = rspArray[1].trim();
//                                                    //接收人
//                                                    detail.receName = rspArray[2].trim();
//                                                    //申请日期
//                                                    detail.applyDate = DateHelper.convertD8toD10(rspArray[4].trim());
//                                                    //地址
//                                                    detail.guarAddr = rspArray[3].trim();
//                                                }
////                                    04回购式贴现背书
////                                    07回购式转贴现背书
////                                    10回购式再贴现背书
////                                    票据类型|背书人名称|被背书人名称|背书日期|赎回开放日|赎回截止日| @|$
//                                                else if ("04".equals(rspArray[0].trim()) || "07".equals(rspArray[0].trim()) || "10".equals(rspArray[0].trim())) {
//                                                    //申请人
//                                                    detail.applyName = rspArray[1].trim();
//                                                    //接收人
//                                                    detail.receName = rspArray[2].trim();
//                                                    //申请日期
//                                                    detail.applyDate = DateHelper.convertD8toD10(rspArray[3].trim());
//                                                    //赎回开放日
//                                                    detail.repOpenDate = DateHelper.convertD8toD10(rspArray[4].trim());
//                                                    //赎回截止日
//                                                    detail.repDueDate = DateHelper.convertD8toD10(rspArray[5].trim());
//                                                }
////                                    14追索清偿
////                                    15再追索清偿
////                                    类型|追索人名称|清偿人名称|追索日期|追索类型|清偿日期| @|$
//                                                else if ("14".equals(rspArray[0].trim()) || "15".equals(rspArray[0].trim())) {
//                                                    //申请人
//                                                    detail.applyName = rspArray[1].trim();
//                                                    //接收人
//                                                    detail.receName = rspArray[2].trim();
//                                                    //申请日期
//                                                    detail.applyDate = DateHelper.convertD8toD10(rspArray[3].trim());
//                                                    detail.respDate = DateHelper.convertD8toD10(rspArray[5].trim());
//                                                    //追索类型
//                                                    if ("RT00".equals(rspArray[4].trim())) {
//                                                        detail.recourseType = "1";
//                                                    } else if ("RT01".equals(rspArray[4].trim())) {
//                                                        detail.recourseType = "2";
//                                                    }
//                                                }
////                                    02质押背书
////                                    类型|出质人名称|质权人名称|出质日期|质押解除日期| @|$
//                                                else if ("02".equals(rspArray[0].trim())) {
//                                                    //申请人
//                                                    detail.applyName = rspArray[1].trim();
//                                                    //接收人
//                                                    detail.receName = rspArray[2].trim();
//                                                    //申请日期
//                                                    detail.applyDate = DateHelper.convertD8toD10(rspArray[3].trim());
//                                                }
////                                    13提示付款
////                                    类型|提示付款人名称|提示付款日期|付款或拒付|付款或拒付日期|拒付理由| @|$
//                                                else if ("13".equals(rspArray[0].trim())) {
//                                                    //申请人
//                                                    detail.applyName = rspArray[1].trim();
//                                                    //接收人
////                                        detail.receName = rspArray[2].trim();
//                                                    //申请日期
//                                                    detail.applyDate = DateHelper.convertD8toD10(rspArray[2].trim());
//                                                    if ("EM00".equals(rspArray[3].trim())) {
//                                                        detail.respFlag = "1";
//                                                    } else if ("EM01".equals(rspArray[3].trim())) {
//                                                        continue;
//                                                    }
//                                                    detail.respDate = DateHelper.convertD8toD10(rspArray[5].trim());
//                                                }
//                                                retAts.writeDetail(detail);
//                                            }
//                                        }
//                                    } else {
//                                        retAts.writeRespCode("-1");
//                                        retAts.writeRespInfo(xln_status + xln_resp_code + xln_resp_desc);
//                                    }
//                                } else {
//                                    retAts.writeRespCode("-1");
//                                    retAts.writeRespInfo(msg.toString());
//                                }
//                            } else {
//                                retAts.writeRespCode("-1");
//                                retAts.writeRespInfo(tmpStrRet[1]);
//                            }
//                        }
//                    } else {
//                        retAts.writeRespCode("-1");
//                        retAts.writeRespInfo("签到失败");
//                    }
//                } else {
//                    retAts.writeRespCode("-1");
//                    retAts.writeRespInfo("下载银行pub密钥失败");
//                }
//            } else {
//                retAts.writeRespCode("-1");
//                retAts.writeRespInfo("下载银行3des密钥失败");
//            }
//
//        } catch (Exception e) {
//            retAts.writeRespCode("-1");
//            retAts.writeRespInfo(e.getMessage());
//            e.printStackTrace();
//        }
//        retAts.writeEnd();
//        return retAts;
//    }
//
//    //票据交易状态查询
//    @Override
//    public RetAtsB006BillStateQry D_B006_BillState_Qeury(ReqB006BillStateQry query) throws Exception {
//        RetAtsB006BillStateQry retAts = new RetAtsB006BillStateQry(query.reqHeader);
//        retAts.writeBeforeDetail();
//        while (query.readRecord()) {
//            if ("1".equals(query.detail.operType) || "4".equals(query.detail.operType)) {
//                queryBillByP1ECDS254(query, retAts);
//            } else {
//                queryBillByP1ECDS269(query, retAts);
//            }
//        }
//        retAts.writeEnd();
//        return retAts;
//    }
//
//    //可追索人查询
//    @Override
//    public RetAtsB007BillKzsrQry D_B007_BillKzsr_Query(ReqB007BillKzsrQry query) throws Exception {
//        RetAtsB007BillKzsrQry retAts = new RetAtsB007BillKzsrQry(query.reqHeader);
//        retAts.writeStart();
//        query.readRecord();
//        retAts.respCode = "0";
//        retAts.billNo = query.detail.billNo;
//        retAts.writeRespInfos();
//        String[] kzsrTypearr = new String[]{"RT00", "RT01"};
//        for (String bkType1 : kzsrTypearr) {
//            try {
//                getBnkToken();
//                if (StringHelper.hasAnyChar(bankFront.token)) {
//                    if (new File(String.format("%1$s%2$s_BnkPubKey.txt", strtmpFile, bankFront.org)).exists()) {
//                        if (!"".equals(bankFront.loginFlag) && !"false".equals(bankFront.loginFlag)) {
//                            txCode = "P1ECDS264";
//                            reqSeqID = getQryTransID();
//                            XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//                            //写入报文头部信息
//                            writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//                            xmlWriterWithoutCDATA.writeStartElement("request");
//                            writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriterWithoutCDATA.writeElementString("BkAmt1", query.detail.billAmt);//原电票票据金额
//                            xmlWriterWithoutCDATA.writeElementString("BkType1", bkType1);//追索类型
//                            xmlWriterWithoutCDATA.writeElementString("Bk8Date1", "");//追索通知日期 TODO
//                            xmlWriterWithoutCDATA.writeElementString("BkAmt2", query.detail.billAmt);//原电票追索金额
//                            String bkRole = getBankConfig().getMapAdvanceValue("accInfo", "key", "opertorRole", query.detail.actNum);
//                            xmlWriterWithoutCDATA.writeElementString("BkRole", bkRole);//追索人类别
//                            xmlWriterWithoutCDATA.writeElementString("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票追索人组织机构代码
//                            xmlWriterWithoutCDATA.writeElementString("Bk60Name1", query.detail.kzsrName);//原电票追索人名称
//                            xmlWriterWithoutCDATA.writeElementString("BkAcctNo1", query.detail.actNum);//原电票追索人账号
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo1", query.detail.kzsrBnkCode);//原电票追索人开户行行号
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo2", "");//原电票追索人承接行行号
//                            xmlWriterWithoutCDATA.writeEndDocument();
//                            int n = xmlWriterWithoutCDATA.toXmlString().length();
//                            xmlLength = decimalFormat.format(n);
//
//                            XmlTextWriter xmlWriter = new XmlTextWriter();
//                            writeCommonHeader(xmlWriter);
//                            xmlWriter.writeStartElement("request");
//                            writeElecBillComEntity(xmlWriter, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriter.writeElementCDATA("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriter.writeElementCDATA("BkAmt1", query.detail.billAmt);//原电票票据金额
//                            xmlWriter.writeElementCDATA("BkType1", bkType1);//追索类型
//                            xmlWriter.writeElementCDATA("Bk8Date1", "");//追索通知日期 TODO
//                            xmlWriter.writeElementCDATA("BkAmt2", query.detail.billAmt);//原电票追索金额
//                            xmlWriterWithoutCDATA.writeElementString("BkRole", bkRole);//追索人类别
//                            xmlWriter.writeElementCDATA("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票追索人组织机构代码
//                            xmlWriter.writeElementCDATA("Bk60Name1", query.detail.kzsrName);//原电票追索人名称
//                            xmlWriter.writeElementCDATA("BkAcctNo1", query.detail.actNum);//原电票追索人账号
//                            xmlWriter.writeElementCDATA("BkBrchNo1", query.detail.kzsrBnkCode);//原电票追索人开户行行号
//                            xmlWriter.writeElementCDATA("BkBrchNo2", "");//原电票追索人承接行行号
//                            xmlWriter.writeEndDocument();
//
//                            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
//
//                            if (tmpStrRet[0].length() == 0) {
//                                StringBuilder msg = new StringBuilder();
//                                XmlTextReader tmpBkReader = getBankInfo(tmpStrRet[1], msg);
//                                if (tmpBkReader != null) {
//                                    String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                                    String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                                    String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                                    if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                                        while (tmpBkReader.read("/Transaction/Transaction_Body/response/Bkzscx_GRP")) {
//                                            RetAtsB007BillKzsrQryDetail detail = new RetAtsB007BillKzsrQryDetail();
//                                            detail.receCode = tmpBkReader.readedXElement.getSingleText("BkInstNo");
//                                            detail.receName = tmpBkReader.readedXElement.getSingleText("Bk60Name3");
//                                            detail.receAct = tmpBkReader.readedXElement.getSingleText("BkAcctNo3");
//                                            detail.receBnkCode = tmpBkReader.readedXElement.getSingleText("BkBrchNo3");
//                                            retAts.writeDetail(detail);
//                                        }
//                                    } else {
//                                        retAts.writeRespCode("-1");
//                                        retAts.writeRespInfo(xln_status + xln_resp_code + xln_resp_desc);
//                                    }
//                                } else {
//                                    retAts.writeRespCode("-1");
//                                    retAts.writeRespInfo(msg.toString());
//                                }
//                            } else {
//                                retAts.writeRespCode("-1");
//                                retAts.writeRespInfo(tmpStrRet[1]);
//                            }
//                        } else {
//                            retAts.writeRespCode("-1");
//                            retAts.writeRespInfo("签到失败");
//                        }
//                    } else {
//                        retAts.writeRespCode("-1");
//                        retAts.writeRespInfo("下载银行pub密钥失败");
//                    }
//                } else {
//                    retAts.writeRespCode("-1");
//                    retAts.writeRespInfo("下载银行3des密钥失败");
//                }
//            } catch (Exception ex) {
//                ex.printStackTrace();
//                retAts.writeRespCode("-1");
//                retAts.writeRespInfo(ex.getMessage());
//            }
//        }
//        retAts.writeEnd();
//        return retAts;
//    }
//
//    //票据操作信息查询
//    @Override
//    public RetAtsB008HistoricalBillQry D_B008_HistoricalBillQuery(ReqB008HistoricalBillQry query) throws Exception {
//        return null;
//    }
//
//    //出票登记查询
//    @Override
//    public RetAtsB009DrawBillQry D_B009_DrawBillQuery(ReqB009DrawBillQry query) throws Exception {
//        return null;
//    }
//
//    //票据协议状态查询
//    @Override
//    public RetAtsB010ProtocolStateQry D_B010_ProtocolStateQuery(ReqB010ProtocolStateQry query) throws Exception {
//        return null;
//    }
//
//    @Override
//    public RetAtsB011TransFlagQry D_B011_TransFlagQuery(ReqB011TransFlagQry query) throws Exception {
//        return null;
//    }
//
//    //查询申请类的票据
//    private void queryBillByApply(ReqB001OperBillQry query, RetAtsB001OperBillQry retAts) throws Exception {
//        switch (Integer.valueOf(query.detail.busiType)) {
//            case 1:
//                if ("1".equals(query.detail.billType)) {
//                    List<String> protocols = queryProtocolsByP1ECDS251();
//                    for (String protocol : protocols) {
//                        queryBillByP1ECDS252(query, retAts, protocol);
//                    }
//                } else {
//                    queryBillByP1ECDS255(query, retAts, "0000");
//                }
//                break;//出票
//            case 2:
//                queryBillByP1ECDS255(query, retAts, "0001");
//                break;//承兑
//            case 3:
//                queryBillByP1ECDS255(query, retAts, "0002");
//                break;//提示收票
//            case 4:
//                queryBillByP1ECDS255(query, retAts, "0004");
//                break;//背书转让
//            case 5:
//                queryBillByP1ECDS255(query, retAts, "0006");
//                break;//质押
//            case 6:
//                queryBillByP1ECDS255(query, retAts, "0007");
//                break;//质押解除
//            case 10:
//                queryBillByP1ECDS255(query, retAts, "0005");
//                break;//贴现
//            case 12:
//                queryBillByP1ECDS255(query, retAts, "0008");
//                break;//提示付款
//            case 13:
//                if ("1".equals(query.detail.recourseType)) {
//                    queryBillByP1ECDS255(query, retAts, "0009");
//                } else {
//                    queryBillByP1ECDS255(query, retAts, "0010");
//                }
//                break;//追索
//            case 14:
//                queryBillByP1ECDS282(query, retAts);
//                break;//同意清偿
//            default:
//                throw new Exception("未知的申请操作类型");
//        }
//    }
//
//    //应答承兑人查询
//    private void queryBillByP1ECDS282(ReqB001OperBillQry query, RetAtsB001OperBillQry retAts) throws Exception {
//        getBnkToken();
//        if (StringHelper.hasAnyChar(bankFront.token)) {
//            if (new File(String.format("%1$s%2$s_BnkPubKey.txt", strtmpFile, bankFront.org)).exists()) {
//                if (!"".equals(bankFront.loginFlag) && !"false".equals(bankFront.loginFlag)) {
//                    txCode = "P1ECDS282";
//                    reqSeqID = getQryTransID();
//
//                    String busiType;
//                    if ("2".equals(query.detail.queryType)) {
//                        switch (Integer.valueOf(query.detail.busiType)) {
//                            case 2:
//                            case 5:
//                            case 6:
//                            case 11:
//                            case 12:
//                            case 14:
//                                busiType = "0001";
//                                break;//其他
//                            case 3:
//                                busiType = "0003";
//                                break;//收票待签收
//                            case 4:
//                                busiType = "0004";
//                                break;//背书待签收
//                            default:
//                                throw new Exception("业务类型未知：" + query.detail.busiType);
//                        }
//                    } else {
//                        busiType = "0002";
//                    }
//
//                    XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//                    //写入报文头部信息
//                    writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//                    xmlWriterWithoutCDATA.writeStartElement("request");
//                    writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                    xmlWriterWithoutCDATA.writeElementString("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票出票人组织机构代码
//                    if ("1".equals(query.detail.billType)) {
//                        xmlWriterWithoutCDATA.writeElementString("BkType1", "AC01");//AC01银承
//                    } else {
//                        xmlWriterWithoutCDATA.writeElementString("BkType1", "AC02");//只能填写 AC02商承
//                    }
//                    xmlWriterWithoutCDATA.writeElementString("Bk8Date1", "");//原电票交易日期
//                    xmlWriterWithoutCDATA.writeElementString("BkType2", busiType);//应答类型
//                    xmlWriterWithoutCDATA.writeElementString("Bk8Date2", "");//原电票申请日期
//                    xmlWriterWithoutCDATA.writeEndDocument();
//                    int n = xmlWriterWithoutCDATA.toXmlString().length();
//                    xmlLength = decimalFormat.format(n);
//
//                    XmlTextWriter xmlWriter = new XmlTextWriter();
//                    writeCommonHeader(xmlWriter);
//                    xmlWriter.writeStartElement("request");
//                    writeElecBillComEntity(xmlWriter, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                    xmlWriter.writeElementCDATA("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票出票人组织机构代码
//                    if ("1".equals(query.detail.billType)) {
//                        xmlWriter.writeElementCDATA("BkType1", "AC01");//AC01银承
//                    } else {
//                        xmlWriter.writeElementCDATA("BkType1", "AC02");//只能填写 AC02商承
//                    }
//                    xmlWriter.writeElementCDATA("Bk8Date1", "");//原电票交易日
//                    xmlWriter.writeElementCDATA("BkType2", busiType);//应开始
//                    xmlWriter.writeElementCDATA("Bk8Date2", "");//原电票申请日
//                    xmlWriter.writeEndDocument();
//
//                    String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
//
//                    if (tmpStrRet[0].length() == 0) {
//                        StringBuilder msg = new StringBuilder();
//                        XmlTextReader tmpBkReader = getBankInfo(tmpStrRet[1], msg);
//                        if (tmpBkReader != null) {
//                            String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                            String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                            String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                            if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                                retAts.writeBefore();
//                                while (tmpBkReader.read("/Transaction/Transaction_Body/response/BkPjxx_GRP")) {
//                                    String ownAcc = tmpBkReader.readedXElement.getSingleText("BkAcctNo1");
//                                    if (StringHelper.hasAnyChar(ownAcc) && ownAcc.contains(query.detail.actNum)) {
//                                        RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
//                                        detail.billNo = tmpBkReader.readedXElement.getSingleText("BkListNo1");
//                                        String billType = tmpBkReader.readedXElement.getSingleText("BkType1");
//                                        if ("AC01".equals(billType)) {
//                                            detail.billType = "EM001";
//                                        } else if ("AC02".equals(billType)) {
//                                            detail.billType = "EM002";
//                                        }
//                                        //<Bk8Date1>出票日期</Bk8Date1>
//                                        detail.issDate = DateHelper.convertD8toD10(tmpBkReader.readedXElement.getSingleText("Bk8Date1"));
//                                        //<Bk8Date2>汇票到期日</Bk8Date2>
//                                        detail.dueDate = DateHelper.convertD8toD10(tmpBkReader.readedXElement.getSingleText("Bk8Date2"));
//                                        //<BkAmt1>出票金额</BkAmt1>
//                                        detail.billAmt = tmpBkReader.readedXElement.getSingleText("BkAmt1");
//                                        //转让标识
//                                        detail.transFlag = "1";
//                                        //承兑无条件支付委托 1-无条件支付 0-非条件支付
//                                        detail.mustPay = "";
//                                        //出票人
//                                        detail.drawName = tmpBkReader.readedXElement.getSingleText("Bk60Name2");
//                                        detail.drawAct = tmpBkReader.readedXElement.getSingleText("BkAcctNo2");
//
//                                        //承兑人开户行
//                                        detail.accpName = tmpBkReader.readedXElement.getSingleText("Bk60Name7");
//                                        detail.accpAct = tmpBkReader.readedXElement.getSingleText("BkAcctNo7");
//                                        detail.accpBnkCode = tmpBkReader.readedXElement.getSingleText("BkBrchNo7");
//                                        //<BkFlag1>票据状态</BkFlag1>
//                                        detail.billStatus = tmpBkReader.readedXElement.getSingleText("BkFlag1");
//                                        //<BkDetail3>备注2</BkDetail3>
//                                        detail.memo = tmpBkReader.readedXElement.getSingleText("BkDetail3");
//                                        retAts.writeDetail(detail);
//                                    }
//                                }
//                            }else if("YBLECDA10000".equals(xln_resp_code)){
//                                retAts.respInfo = xln_status + xln_resp_code + xln_resp_desc;
//                            } else {
//                                retAts.respCode = "-1";
//                                retAts.respInfo = xln_status + xln_resp_code + xln_resp_desc;
//                                retAts.writeBefore();
//                            }
//                        } else {
//                            retAts.respCode = "-1";
//                            retAts.respInfo = msg.toString();
//                            retAts.writeBefore();
//                        }
//                    } else {
//                        retAts.respCode = "-1";
//                        retAts.respInfo = tmpStrRet[1];
//                        retAts.writeBefore();
//                    }
//                } else {
//                    retAts.respCode = "-1";
//                    retAts.respInfo = "签到失败";
//                    retAts.writeBefore();
//                }
//            } else {
//                retAts.respCode = "-1";
//                retAts.respInfo = "下载银行pub密钥失败";
//                retAts.writeBefore();
//            }
//        } else {
//            retAts.respCode = "-1";
//            retAts.respInfo = "下载银行3des密钥失败";
//            retAts.writeBefore();
//        }
//    }
//
//    //协议出票信息查询
//    //todo
//    private void queryBillByP1ECDS252(ReqB001OperBillQry query, RetAtsB001OperBillQry retAts, String protocol) {
//
//    }
//
//    //todo
//    private List<String> queryProtocolsByP1ECDS251() {
//        List<String> protocols = new ArrayList<String>();
//
//
//        return protocols;
//    }
//
//    //持票查询
//    private void queryBillByP1ECDS255(ReqB001OperBillQry query, RetAtsB001OperBillQry retAts, String billTransType) throws Exception {
//        getBnkToken();
//        if (StringHelper.hasAnyChar(bankFront.token)) {
//            if (new File(String.format("%1$s%2$s_BnkPubKey.txt", strtmpFile, bankFront.org)).exists()) {
//                if (!"".equals(bankFront.loginFlag) && !"false".equals(bankFront.loginFlag)) {
//                    txCode = "P1ECDS255";
//                    reqSeqID = getQryTransID();
//                    XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//                    //写入报文头部信息
//                    writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//                    xmlWriterWithoutCDATA.writeStartElement("request");
//                    writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                    xmlWriterWithoutCDATA.writeElementString("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票组织机构代码
//                    if ("1".equals(query.detail.billType)) {
//                        xmlWriterWithoutCDATA.writeElementString("BkType1", "AC01");//AC01银承
//                    } else {
//                        xmlWriterWithoutCDATA.writeElementString("BkType1", "AC02");//只能填写 AC02商承
//                    }
//                    xmlWriterWithoutCDATA.writeElementString("BkType2", billTransType);//原电票交易类型
//                    xmlWriterWithoutCDATA.writeElementString("Bk60Name1", "");//原电票出票人名称
//                    xmlWriterWithoutCDATA.writeElementString("BkFlag1", "");//票据状态
//                    xmlWriterWithoutCDATA.writeElementString("Bk8Date1", DateHelper.convertDateTimetoD8(query.detail.dueDateDown));//票据到期日开始
//                    xmlWriterWithoutCDATA.writeElementString("Bk8Date2", DateHelper.convertDateTimetoD8(query.detail.dueDateUp));//票据到期日结束
//                    xmlWriterWithoutCDATA.writeElementString("BkAmt1", query.detail.billAmtDown);//票据金额开始
//                    xmlWriterWithoutCDATA.writeElementString("BkAmt2", query.detail.billAmtUp);//票据金额结束
//                    xmlWriterWithoutCDATA.writeElementString("Bk60Name2", "");//承兑银行名称
//                    xmlWriterWithoutCDATA.writeElementString("BkListNo1", query.detail.billNo);//原电票汇票号码
//                    xmlWriterWithoutCDATA.writeElementString("Bk8Date3", "");//票据出票日开始
//                    xmlWriterWithoutCDATA.writeElementString("Bk8Date4", "");//票据出票日结束
//                    xmlWriterWithoutCDATA.writeElementString("BkType4", "");//集团划转标志
//                    xmlWriterWithoutCDATA.writeElementString("Bk8Date5", "");//应答开始日期
//                    xmlWriterWithoutCDATA.writeElementString("Bk8Date6", "");//应答结束日期
//                    xmlWriterWithoutCDATA.writeElementString("BkOthName", "");//原电票收款人名称
//                    xmlWriterWithoutCDATA.writeElementString("BkAcctNum", "1");//账号数量
//                    xmlWriterWithoutCDATA.writeStartElement("BkAcctQuery_GRP");
//                    xmlWriterWithoutCDATA.writeElementString("BkEcdQueryAcct", query.detail.actNum);//账号数量
//                    xmlWriterWithoutCDATA.writeEndElement();
//                    xmlWriterWithoutCDATA.writeEndDocument();
//                    int n = xmlWriterWithoutCDATA.toXmlString().length();
//                    xmlLength = decimalFormat.format(n);
//
//                    XmlTextWriter xmlWriter = new XmlTextWriter();
//                    writeCommonHeader(xmlWriter);
//                    xmlWriter.writeStartElement("request");
//                    writeElecBillComEntity(xmlWriter, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                    xmlWriter.writeElementCDATA("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票出票人组织机构代码
//                    if ("1".equals(query.detail.billType)) {
//                        xmlWriter.writeElementCDATA("BkType1", "AC01");//AC01银承
//                    } else {
//                        xmlWriter.writeElementCDATA("BkType1", "AC02");//只能填写 AC02商承
//                    }
//                    xmlWriter.writeElementCDATA("BkType2", billTransType);//原电票交易类型
//                    xmlWriter.writeElementCDATA("Bk60Name1", "");//原电票出票人名称
//                    xmlWriter.writeElementCDATA("BkFlag1", "");//票据状态
//                    xmlWriter.writeElementCDATA("Bk8Date1", DateHelper.convertDateTimetoD8(query.detail.dueDateDown));//票据到期日开始
//                    xmlWriter.writeElementCDATA("Bk8Date2", DateHelper.convertDateTimetoD8(query.detail.dueDateUp));//票据到期日结束
//                    xmlWriter.writeElementCDATA("BkAmt1", query.detail.billAmtDown);//票据金额开始
//                    xmlWriter.writeElementCDATA("BkAmt2", query.detail.billAmtUp);//票据金额结束
//                    xmlWriter.writeElementCDATA("Bk60Name2", "");//承兑银行名称
//                    xmlWriter.writeElementCDATA("BkListNo1", query.detail.billNo);//原电票汇票号码
//                    xmlWriter.writeElementCDATA("Bk8Date3", "");//票据出票日开始
//                    xmlWriter.writeElementCDATA("Bk8Date4", "");//票据出票日结束
//                    xmlWriter.writeElementCDATA("BkType4", "");//集团划转标志
//                    xmlWriter.writeElementCDATA("Bk8Date5", "");//应答开始日期
//                    xmlWriter.writeElementCDATA("Bk8Date6", "");//应答结束日期
//                    xmlWriter.writeElementCDATA("BkOthName", "");//原电票收款人名称
//                    xmlWriter.writeElementCDATA("BkAcctNum", "1");//账号数量
//                    xmlWriter.writeStartElement("BkAcctQuery_GRP");
//                    xmlWriter.writeElementCDATA("BkEcdQueryAcct", query.detail.actNum);//账号数量
//                    xmlWriter.writeEndElement();
//                    xmlWriter.writeEndDocument();
//
//                    String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
//
//                    if (tmpStrRet[0].length() == 0) {
//                        StringBuilder msg = new StringBuilder();
//                        XmlTextReader tmpBkReader = getBankInfo(tmpStrRet[1], msg);
//                        if (tmpBkReader != null) {
//                            String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                            String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                            String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                            if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                                retAts.writeBefore();
//                                while (tmpBkReader.read("/Transaction/Transaction_Body/response/BkPjxx_GRP")) {
//                                    String ownAcc = tmpBkReader.readedXElement.getSingleText("BkAcctNo1");
//                                    if (StringHelper.hasAnyChar(ownAcc) && ownAcc.contains(query.detail.actNum)) {
//                                        RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
//                                        detail.billNo = tmpBkReader.readedXElement.getSingleText("BkListNo1");
//                                        String billType = tmpBkReader.readedXElement.getSingleText("BkType1");
//                                        if ("AC01".equals(billType)) {
//                                            detail.billType = "EM001";
//                                        } else if ("AC02".equals(billType)) {
//                                            detail.billType = "EM002";
//                                        }
//                                        //<Bk8Date1>出票日期</Bk8Date1>
//                                        detail.issDate = DateHelper.convertD8toD10(tmpBkReader.readedXElement.getSingleText("Bk8Date1"));
//                                        //<Bk8Date2>汇票到期日</Bk8Date2>
//                                        detail.dueDate = DateHelper.convertD8toD10(tmpBkReader.readedXElement.getSingleText("Bk8Date2"));
//                                        //<BkAmt1>出票金额</BkAmt1>
//                                        detail.billAmt = tmpBkReader.readedXElement.getSingleText("BkAmt1");
//                                        //转让标识
//                                        detail.transFlag = "1";
//                                        //承兑无条件支付委托 1-无条件支付 0-非条件支付
//                                        detail.mustPay = "";
//                                        //出票人
//                                        detail.drawName = tmpBkReader.readedXElement.getSingleText("Bk60Name2");
//                                        detail.drawAct = tmpBkReader.readedXElement.getSingleText("BkAcctNo2");
//
//                                        //承兑人开户行
//                                        detail.accpName = tmpBkReader.readedXElement.getSingleText("Bk60Name7");
//                                        detail.accpAct = tmpBkReader.readedXElement.getSingleText("BkAcctNo7");
//                                        detail.accpBnkCode = tmpBkReader.readedXElement.getSingleText("BkBrchNo7");
//                                        //<BkFlag1>票据状态</BkFlag1>
//                                        detail.billStatus = tmpBkReader.readedXElement.getSingleText("BkFlag1");
//                                        //<BkDetail3>备注2</BkDetail3>
//                                        detail.memo = tmpBkReader.readedXElement.getSingleText("BkDetail3");
//                                        retAts.writeDetail(detail);
//                                    }
//                                }
//                            }else if("YBLECDA10000".equals(xln_resp_code)){
//                                retAts.respInfo = xln_status + xln_resp_code + xln_resp_desc;
//                                retAts.writeBefore();
//                            } else {
//                                retAts.respCode = "-1";
//                                WriteBankLogLn(xln_status + xln_resp_code + xln_resp_desc);
//                                retAts.respInfo = xln_status + xln_resp_code + xln_resp_desc;
//                                retAts.writeBefore();
//                            }
//                        } else {
//                            retAts.respCode = "-1";
//                            retAts.respInfo = msg.toString();
//                            retAts.writeBefore();
//                        }
//                    } else {
//                        retAts.respCode = "-1";
//                        retAts.respInfo = tmpStrRet[1];
//                        retAts.writeBefore();
//                    }
//                } else {
//                    retAts.respCode = "-1";
//                    retAts.respInfo = "签到失败";
//                    retAts.writeBefore();
//                }
//            } else {
//                retAts.respCode = "-1";
//                retAts.respInfo = "下载银行pub密钥失败";
//                retAts.writeBefore();
//            }
//        } else {
//            retAts.respCode = "-1";
//            retAts.respInfo = "下载银行3des密钥失败";
//            retAts.writeBefore();
//        }
//    }
//
//    //结果查询
//    private void queryBillByP1ECDS254(ReqB006BillStateQry query, RetAtsB006BillStateQry retAts) {
//        try {
//            RetAtsB006BillStateQryDetail detail = new RetAtsB006BillStateQryDetail();
//            getBnkToken();
//            if (StringHelper.hasAnyChar(bankFront.token)) {
//                if (new File(String.format("%1$s%2$s_BnkPubKey.txt", strtmpFile, bankFront.org)).exists()) {
//                    if (!"".equals(bankFront.loginFlag) && !"false".equals(bankFront.loginFlag)) {
//                        txCode = "P1ECDS254";
//                        reqSeqID = getQryTransID();
//                        //原电票交易类型
//                        String busiType = "";
//                        if ("1".equals(query.detail.operType)) {
//                            switch (Integer.valueOf(query.detail.busiType)) {
//                                case 1:
//                                    busiType = "0000";
//                                    break;
//                                case 2:
//                                    busiType = "0001";
//                                    break;
//                                case 3:
//                                    busiType = "0002";
//                                    break;
//                                case 4:
//                                    busiType = "0004";
//                                    break;
//                                case 5:
//                                    busiType = "0006";
//                                    break;
//                                case 6:
//                                    busiType = "0007";
//                                    break;
//                                case 10:
//                                    busiType = "0005";
//                                    break;
//                                case 12:
//                                    busiType = "0008";
//                                    break;
//                                case 13:
//                                    busiType = "0009";
//                                    break;
//                                case 14:
//                                    busiType = "0010";
//                                    break;
//                                default: {
//                                    throw new Exception("不支持的申请查询类型：" + query.detail.operType);
//                                }
//                            }
//                        } else if ("4".equals(query.detail.operType)) {
//                            switch (Integer.valueOf(query.detail.busiType)) {
//                                case 1:
//                                    busiType = "0003";
//                                    break;
//                                case 2:
//                                    busiType = "0015";
//                                    break;
//                                case 3:
//                                    busiType = "0016";
//                                    break;
//                                case 4:
//                                    busiType = "0017";
//                                    break;
//                                case 5:
//                                    busiType = "0019";
//                                    break;
//                                case 6:
//                                    busiType = "0020";
//                                    break;
//                                case 10:
//                                    busiType = "0018";
//                                    break;
//                                case 12:
//                                    busiType = "0021";
//                                    break;
//                                case 13:
//                                    busiType = "0022";
//                                    break;
//                                case 14:
//                                    busiType = "0023";
//                                    break;
//                                default:
//                                    throw new Exception("不支持的撤销查询类型：" + query.detail.operType);
//                            }
//                        }
//                        XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//                        //写入报文头部信息
//                        writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//                        xmlWriterWithoutCDATA.writeStartElement("request");
//                        writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                        xmlWriterWithoutCDATA.writeElementString("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//TODO 原电票出票人组织机构代码
//                        if ("1".equals(query.detail.billType)) {
//                            xmlWriterWithoutCDATA.writeElementString("BkType1", "AC01");//AC01银承
//                        } else {
//                            xmlWriterWithoutCDATA.writeElementString("BkType1", "AC02");//只能填写 AC02商承
//                        }
//                        xmlWriterWithoutCDATA.writeElementString("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                        xmlWriterWithoutCDATA.writeElementString("BkFlag1", "");//票据状态
//                        xmlWriterWithoutCDATA.writeElementString("BkType2", busiType);//原电票交易类型
//                        xmlWriterWithoutCDATA.writeElementString("Bk8Date1", "");//查询起始日期
//                        xmlWriterWithoutCDATA.writeElementString("Bk8Date2", "");//查询结束日期
//                        xmlWriterWithoutCDATA.writeElementString("BkAmt1", "");//票据金额开始
//                        xmlWriterWithoutCDATA.writeElementString("BkAmt2", "");//票据金额结束
//                        xmlWriterWithoutCDATA.writeElementString("Bk8Date3", "");//票据到期日开始
//                        xmlWriterWithoutCDATA.writeElementString("Bk8Date4", "");//票据到期日结束
//                        xmlWriterWithoutCDATA.writeElementString("Bk60Name1", "");//原电票收款人名称
//                        xmlWriterWithoutCDATA.writeElementString("BkListNo2", "");//原电票协议编号
//                        xmlWriterWithoutCDATA.writeElementString("BkListNo3", "");//下载自动任务编号
//                        xmlWriterWithoutCDATA.writeElementString("BkType7", "");//交易结果类型
//                        xmlWriterWithoutCDATA.writeElementString("BkAcctNum", "1");//账号数量
//                        xmlWriterWithoutCDATA.writeStartElement("BkAcctQuery_GRP");
//                        xmlWriterWithoutCDATA.writeElementString("BkEcdQueryAcct", query.detail.actNum);//账号数量
//                        xmlWriterWithoutCDATA.writeEndElement();
//                        xmlWriterWithoutCDATA.writeEndDocument();
//                        int n = xmlWriterWithoutCDATA.toXmlString().length();
//                        xmlLength = decimalFormat.format(n);
//
//                        XmlTextWriter xmlWriter = new XmlTextWriter();
//                        writeCommonHeader(xmlWriter);
//                        xmlWriter.writeStartElement("request");
//                        writeElecBillComEntity(xmlWriter, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                        xmlWriter.writeElementCDATA("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//TODO 原电票出票人组织机构代码
//                        if ("1".equals(query.detail.billType)) {
//                            xmlWriter.writeElementCDATA("BkType1", "AC01");//AC01银承
//                        } else {
//                            xmlWriter.writeElementCDATA("BkType1", "AC02");//只能填写 AC02商承
//                        }
//                        xmlWriter.writeElementCDATA("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                        xmlWriter.writeElementCDATA("BkFlag1", "");//票据状态
//                        xmlWriter.writeElementCDATA("BkType2", busiType);//原电票交易类型
//                        xmlWriter.writeElementCDATA("Bk8Date1", "");//查询起始日期
//                        xmlWriter.writeElementCDATA("Bk8Date2", "");//查询结束日期
//                        xmlWriter.writeElementCDATA("BkAmt1", "");//票据金额开始
//                        xmlWriter.writeElementCDATA("BkAmt2", "");//票据金额结束
//                        xmlWriter.writeElementCDATA("Bk8Date3", "");//票据到期日开始
//                        xmlWriter.writeElementCDATA("Bk8Date4", "");//票据到期日结束
//                        xmlWriter.writeElementCDATA("Bk60Name1", "");//原电票收款人名称
//                        xmlWriter.writeElementCDATA("BkListNo2", "");//原电票协议编号
//                        xmlWriter.writeElementCDATA("BkListNo3", "");//下载自动任务编号
//                        xmlWriter.writeElementCDATA("BkType7", "");//交易结果类型
//                        xmlWriter.writeElementCDATA("BkAcctNum", "1");//账号数量
//                        xmlWriter.writeStartElement("BkAcctQuery_GRP");
//                        xmlWriter.writeElementCDATA("BkEcdQueryAcct", query.detail.actNum);//账号数量
//                        xmlWriter.writeEndElement();
//                        xmlWriter.writeEndDocument();
//
//                        String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
//
//                        if (tmpStrRet[0].length() == 0) {
//                            StringBuilder msg = new StringBuilder();
//                            XmlTextReader tmpBkReader = getBankInfo(tmpStrRet[1], msg);
//                            if (tmpBkReader != null) {
//                                String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                                String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                                String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                                if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                                    String ERR_RET = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/ECDS_RSP_INFO/__ERR_RET");
//                                    String ERR_MSG = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/ECDS_RSP_INFO/__ERR_MSG");
//                                    if ("000000000000".equals(ERR_RET)) {
//                                        while (tmpBkReader.read("/Transaction/Transaction_Body/response/BkPjxx_GRP")) {
//                                            String memo = tmpBkReader.readedXElement.getSingleText("BkDetail3");
//                                            String billNo = tmpBkReader.readedXElement.getSingleText("BkListNo1");
//                                            if ((StringHelper.hasAnyChar(memo) && memo.contains(query.detail.reqSeqID))||(StringHelper.hasAnyChar(billNo) && billNo.contains(query.detail.billNo))) {
//                                                detail.respCode = "0";
//                                                detail.respInfo = tmpBkReader.readedXElement.getSingleText("BkSumry");
//                                                detail.reqSeqID = query.detail.reqSeqID;
//                                                detail.billNo = tmpBkReader.readedXElement.getSingleText("BkListNo1");
//                                                detail.billState = tmpBkReader.readedXElement.getSingleText("BkFlag1");
//                                                detail.transState = tmpBkReader.readedXElement.getSingleText("BkFlag2");
//                                                detail.payInfoCode = detail.transState;
//                                                //break;
//                                            }
//                                        }
//                                    } else {
//                                        detail.respCode = "-1";
//                                        detail.respInfo = ERR_RET + ERR_MSG;
//                                    }
//                                } else {
//                                    detail.respCode = "-1";
//                                    detail.respInfo = xln_status + xln_resp_code + xln_resp_desc;
//                                }
//                            } else {
//                                detail.respCode = "-1";
//                                detail.respInfo = msg.toString();
//                            }
//                        } else {
//                            detail.respCode = "-1";
//                            detail.respInfo = tmpStrRet[1];
//                        }
//                    } else {
//                        detail.respCode = "-1";
//                        detail.respInfo = "签到失败";
//                    }
//                } else {
//                    detail.respCode = "-1";
//                    detail.respInfo = "下载银行pub密钥失败";
//                }
//            } else {
//                detail.respCode = "-1";
//                detail.respInfo = "下载银行3des密钥失败";
//            }
//            retAts.writeDetail(detail);
//        } catch (Exception e) {
//            e.printStackTrace();
//            WriteBankLogLn("查询异常");
//        }
//    }
//
//    //结果查询
//    private void queryBillByP1ECDS254(ReqB001OperBillQry query, RetAtsB001OperBillQry retAts, String transType, String billStatus) {
//        try {
//            int monthLength = getBankConfig().getValueAsInt("DateBeforeNow");
//            if (monthLength <= 0) {
//                monthLength = 3;
//            }
//            Calendar tmpCalendarTo = Calendar.getInstance();
//            Calendar tmpCalendarFrom = Calendar.getInstance();
//            tmpCalendarFrom.add(Calendar.MONTH, 0 - monthLength);
//            int tmpIntDateFrom = 0;
//            int tmpIntDateTo = 0;
//            retAts.writeBefore();
//
//            while (tmpIntDateFrom <= tmpIntDateTo) {
//                Calendar tmpClndrStepTo = Calendar.getInstance();
//                tmpClndrStepTo.setTime(tmpCalendarFrom.getTime());
//                //判断是否跨月
//                if (DateHelper.compareMonth(tmpCalendarFrom, tmpCalendarTo) == -1) {
//                    //跨月则设置为月末
//                    tmpClndrStepTo.set(Calendar.DAY_OF_MONTH, tmpClndrStepTo.getActualMaximum(Calendar.DAY_OF_MONTH));
//                } else {
//                    tmpClndrStepTo.setTime(tmpCalendarTo.getTime());
//                }
//                getBnkToken();
//                if (StringHelper.hasAnyChar(bankFront.token)) {
//                    if (new File(String.format("%1$s%2$s_BnkPubKey.txt", strtmpFile, bankFront.org)).exists()) {
//                        if (!"".equals(bankFront.loginFlag) && !"false".equals(bankFront.loginFlag)) {
//                            txCode = "P1ECDS254";
//                            reqSeqID = getQryTransID();
//                            XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//                            //写入报文头部信息
//                            writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//                            xmlWriterWithoutCDATA.writeStartElement("request");
//                            writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriterWithoutCDATA.writeElementString("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//TODO 原电票出票人组织机构代码
//                            if ("1".equals(query.detail.billType)) {
//                                xmlWriterWithoutCDATA.writeElementString("BkType1", "AC01");//AC01银承
//                            } else {
//                                xmlWriterWithoutCDATA.writeElementString("BkType1", "AC02");//只能填写 AC02商承
//                            }
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriterWithoutCDATA.writeElementString("BkFlag1", billStatus);//票据状态
//                            xmlWriterWithoutCDATA.writeElementString("BkType2", transType);//原电票交易类型
//                            xmlWriterWithoutCDATA.writeElementString("Bk8Date1", Format.Date8Format.format(tmpCalendarFrom.getTime()));//查询起始日期
//                            xmlWriterWithoutCDATA.writeElementString("Bk8Date2", Format.Date8Format.format(tmpClndrStepTo.getTime()));//查询结束日期
//                            xmlWriterWithoutCDATA.writeElementString("BkAmt1", "");//票据金额开始
//                            xmlWriterWithoutCDATA.writeElementString("BkAmt2", "");//票据金额结束
//                            xmlWriterWithoutCDATA.writeElementString("Bk8Date3", "");//票据到期日开始
//                            xmlWriterWithoutCDATA.writeElementString("Bk8Date4", "");//票据到期日结束
//                            xmlWriterWithoutCDATA.writeElementString("Bk60Name1", "");//原电票收款人名称
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo2", "");//原电票协议编号
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo3", "");//下载自动任务编号
//                            xmlWriterWithoutCDATA.writeElementString("BkType7", "");//交易结果类型
//                            xmlWriterWithoutCDATA.writeElementString("BkAcctNum", "1");//账号数量
//                            xmlWriterWithoutCDATA.writeStartElement("BkAcctQuery_GRP");
//                            xmlWriterWithoutCDATA.writeElementString("BkEcdQueryAcct", query.detail.actNum);//账号数量
//                            xmlWriterWithoutCDATA.writeEndElement();
//                            xmlWriterWithoutCDATA.writeEndDocument();
//                            int n = xmlWriterWithoutCDATA.toXmlString().length();
//                            xmlLength = decimalFormat.format(n);
//
//                            XmlTextWriter xmlWriter = new XmlTextWriter();
//                            writeCommonHeader(xmlWriter);
//                            xmlWriter.writeStartElement("request");
//                            writeElecBillComEntity(xmlWriter, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriter.writeElementCDATA("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//TODO 原电票出票人组织机构代码
//                            if ("1".equals(query.detail.billType)) {
//                                xmlWriter.writeElementCDATA("BkType1", "AC01");//AC01银承
//                            } else {
//                                xmlWriter.writeElementCDATA("BkType1", "AC02");//只能填写 AC02商承
//                            }
//                            xmlWriter.writeElementCDATA("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriter.writeElementCDATA("BkFlag1", billStatus);//票据状态
//                            xmlWriter.writeElementCDATA("BkType2", transType);//原电票交易类型
//                            String beginDate = Format.Date8Format.format(tmpCalendarFrom.getTime());
//                            String endDate = Format.Date8Format.format(tmpClndrStepTo.getTime());
//                            xmlWriter.writeElementCDATA("Bk8Date1", beginDate);//查询起始日期
//                            xmlWriter.writeElementCDATA("Bk8Date2", endDate);//查询结束日期
//                            xmlWriter.writeElementCDATA("BkAmt1", "");//票据金额开始
//                            xmlWriter.writeElementCDATA("BkAmt2", "");//票据金额结束
//                            xmlWriter.writeElementCDATA("Bk8Date3", "");//票据到期日开始
//                            xmlWriter.writeElementCDATA("Bk8Date4", "");//票据到期日结束
//                            xmlWriter.writeElementCDATA("Bk60Name1", "");//原电票收款人名称
//                            xmlWriter.writeElementCDATA("BkListNo2", "");//原电票协议编号
//                            xmlWriter.writeElementCDATA("BkListNo3", "");//下载自动任务编号
//                            xmlWriter.writeElementCDATA("BkType7", "");//交易结果类型
//                            xmlWriter.writeElementCDATA("BkAcctNum", "1");//账号数量
//                            xmlWriter.writeStartElement("BkAcctQuery_GRP");
//                            xmlWriter.writeElementCDATA("BkEcdQueryAcct", query.detail.actNum);//账号数量
//                            xmlWriter.writeEndElement();
//                            xmlWriter.writeEndDocument();
//
//                            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
//
//                            if (tmpStrRet[0].length() == 0) {
//                                StringBuilder msg = new StringBuilder();
//                                XmlTextReader tmpBkReader = getBankInfo(tmpStrRet[1], msg);
//                                if (tmpBkReader != null) {
//                                    String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                                    String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                                    String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                                    if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                                        while (tmpBkReader.read("/Transaction/Transaction_Body/response/BkPjxx_GRP")) {
//                                            String applyNum = tmpBkReader.readedXElement.getSingleText("BkAcctNo7");
//                                            if (StringHelper.hasAnyChar(applyNum) && applyNum.equals(query.detail.actNum)) {
//                                                RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
//                                                detail.billNo = tmpBkReader.readedXElement.getSingleText("BkListNo1");
//                                                detail.billAmt = tmpBkReader.readedXElement.getSingleText("BkAmt1");
//                                                detail.billType = "1".equals(query.detail.billType) ? "EM001" : "EM002";
//                                                detail.issDate = DateHelper.convertD8toD10(tmpBkReader.readedXElement.getSingleText("Bk8Date1"));
//                                                detail.dueDate = DateHelper.convertD8toD10(tmpBkReader.readedXElement.getSingleText("Bk8Date2"));
//                                                detail.drawAct = tmpBkReader.readedXElement.getSingleText("BkAcctNo1");
//                                                detail.drawName = tmpBkReader.readedXElement.getSingleText("Bk60Name1");
//                                                detail.drawBnkCode = tmpBkReader.readedXElement.getSingleText("BkBrchNo1");
//                                                detail.accpName = tmpBkReader.readedXElement.getSingleText("Bk60Name4");
//                                                detail.accpBnkCode = tmpBkReader.readedXElement.getSingleText("BkBrchNo4");
//                                                detail.payeeAct = tmpBkReader.readedXElement.getSingleText("BkAcctNo2");
//                                                detail.payeeName = tmpBkReader.readedXElement.getSingleText("Bk60Name2");
//                                                detail.payeeBnkCode = tmpBkReader.readedXElement.getSingleText("BkBrchNo2");
//                                                detail.billStatus = tmpBkReader.readedXElement.getSingleText("BkFlag1");
//                                                detail.busiNo = tmpBkReader.readedXElement.getSingleText("BkOldPlatDate") + "_" +
//                                                        tmpBkReader.readedXElement.getSingleText("BkOldSeq");
//                                                retAts.writeDetail(detail);
//                                            }
//                                        }
//                                    }else if("YBLECDA10000".equals(xln_resp_code)){
//                                        WriteBankLogLn("查询"+beginDate+"-"+endDate+"失败:"+xln_status + xln_resp_code + xln_resp_desc);
//                                    } else {
//                                        WriteBankLogLn("查询"+beginDate+"-"+endDate+"失败:"+xln_status + xln_resp_code + xln_resp_desc);
//                                    }
//                                } else {
//                                    WriteBankLogLn("查询"+beginDate+"-"+endDate+"失败:"+msg.toString());
//                                }
//                            } else {
//                                WriteBankLogLn("查询"+beginDate+"-"+endDate+"失败:"+tmpStrRet[1]);
//                            }
//                        } else {
//                            WriteBankLogLn("签到失败");
//                        }
//                    } else {
//                        WriteBankLogLn("下载银行pub密钥失败");
//                    }
//                } else {
//                    WriteBankLogLn("下载银行3des密钥失败");
//                }
//                tmpCalendarFrom = tmpClndrStepTo;
//                tmpCalendarFrom.add(Calendar.DAY_OF_MONTH, 1);
//                tmpIntDateFrom = Integer.parseInt(Format.Date8Format.format(tmpCalendarFrom.getTime()));
//                tmpIntDateTo = Integer.parseInt(Format.Date8Format.format(tmpCalendarTo.getTime()));
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//            WriteBankLogLn("查询异常");
//        }
//    }
//
//    //应答结果查询
//    private void queryBillByP1ECDS269(ReqB006BillStateQry query, RetAtsB006BillStateQry retAts) {
//        try {
//            RetAtsB006BillStateQryDetail detail = new RetAtsB006BillStateQryDetail();
//            getBnkToken();
//            if (StringHelper.hasAnyChar(bankFront.token)) {
//                if (new File(String.format("%1$s%2$s_BnkPubKey.txt", strtmpFile, bankFront.org)).exists()) {
//                    if (!"".equals(bankFront.loginFlag) && !"false".equals(bankFront.loginFlag)) {
//                        txCode = "P1ECDS269";
//                        reqSeqID = getQryTransID();
//                        //原电票交易类型
//                        String busiType = "";
//                        switch (Integer.valueOf(query.detail.busiType)) {
//                            case 2:
//                                busiType = "0001";
//                                break;
//                            case 3:
//                                busiType = "0002";
//                                break;
//                            case 4:
//                                busiType = "0003";
//                                break;
//                            case 5:
//                                busiType = "0012";
//                                break;
//                            case 6:
//                                busiType = "0013";
//                                break;
//                            case 7:
//                                busiType = "0011";
//                                break;
//                            case 8:
//                                busiType = "0011";
//                                break;
//                            case 9:
//                                busiType = "0011";
//                                break;
//                            case 10:
//                                busiType = "0004";
//                                break;
//                            case 11:
//                                busiType = "0005";
//                                break;
//                            case 12:
//                                if ("2".equals(query.detail.overdueFlag)) {
//                                    busiType = "0015";//逾期提示付款
//                                } else {
//                                    busiType = "0014";//正常提示付款
//                                }
//                                break;
//                            case 13:
//                                throw new Exception("暂不支持追索回复");
//                            case 14:
//                                busiType = "0016";
//                                break;
//                            default:
//                                throw new Exception("类型异常：" + query.detail.busiType);
//                        }
//                        String replayType = "";
//                        if ("2".equals(query.detail.operType)) {
//                            replayType = "SU00";
//                        } else if ("3".equals(query.detail.operType)) {
//                            replayType = "SU01";
//                        }
//                        //7-出票保证 8-承兑保证 9-背书保证
//                        String ensureType = "";
//                        if ("7".equals(query.detail.busiType)) {
//                            ensureType = "0";
//                        } else if ("8".equals(query.detail.busiType)) {
//                            ensureType = "1";
//                        } else if ("9".equals(query.detail.busiType)) {
//                            ensureType = "2";
//                        }
//                        XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//                        //写入报文头部信息
//                        writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//                        xmlWriterWithoutCDATA.writeStartElement("request");
//                        writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                        xmlWriterWithoutCDATA.writeElementString("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//TODO 原电票出票人组织机构代码
//                        if ("1".equals(query.detail.billType)) {
//                            xmlWriterWithoutCDATA.writeElementString("BkType1", "AC01");//AC01银承
//                        } else {
//                            xmlWriterWithoutCDATA.writeElementString("BkType1", "AC02");//只能填写 AC02商承
//                        }
//                        xmlWriterWithoutCDATA.writeElementString("BkType2", busiType);//原电票交易类型
//                        xmlWriterWithoutCDATA.writeElementString("Bk8Date1", "");//查询起始日期
//                        xmlWriterWithoutCDATA.writeElementString("Bk8Date2", "");//查询结束日期
//                        xmlWriterWithoutCDATA.writeElementString("BkType3", replayType);//应答标识
//                        xmlWriterWithoutCDATA.writeElementString("BkFlag3", ensureType);//保证类别
//                        xmlWriterWithoutCDATA.writeElementString("BkListNo1", "");//下载自动任务编号
//                        xmlWriterWithoutCDATA.writeElementString("BkType7", "");//交易结果类型
//                        xmlWriterWithoutCDATA.writeElementString("BkType8", "");//电票清算方式
//                        xmlWriterWithoutCDATA.writeElementString("BkAcctNum", "1");//账号数量
//                        xmlWriterWithoutCDATA.writeStartElement("BkAcctQuery_GRP");
//                        xmlWriterWithoutCDATA.writeElementString("BkEcdQueryAcct", query.detail.actNum);//账号数量
//                        xmlWriterWithoutCDATA.writeEndElement();
//                        xmlWriterWithoutCDATA.writeEndDocument();
//                        int n = xmlWriterWithoutCDATA.toXmlString().length();
//                        xmlLength = decimalFormat.format(n);
//
//                        XmlTextWriter xmlWriter = new XmlTextWriter();
//                        writeCommonHeader(xmlWriter);
//                        xmlWriter.writeStartElement("request");
//                        writeElecBillComEntity(xmlWriter, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                        xmlWriter.writeElementCDATA("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//TODO 原电票出票人组织机构代码
//                        if ("1".equals(query.detail.billType)) {
//                            xmlWriter.writeElementCDATA("BkType1", "AC01");//AC01银承
//                        } else {
//                            xmlWriter.writeElementCDATA("BkType1", "AC02");//只能填写 AC02商承
//                        }
//                        xmlWriter.writeElementCDATA("BkType2", busiType);//原电票交易类型
//                        xmlWriter.writeElementCDATA("Bk8Date1", "");//查询起始日期
//                        xmlWriter.writeElementCDATA("Bk8Date2", "");//查询结束日期
//                        xmlWriter.writeElementCDATA("BkType3", replayType);//应答标识
//                        xmlWriter.writeElementCDATA("BkFlag3", ensureType);//保证类别
//                        xmlWriter.writeElementCDATA("BkListNo1", "");//下载自动任务编号
//                        xmlWriter.writeElementCDATA("BkType7", "");//交易结果类型
//                        xmlWriter.writeElementCDATA("BkType8", "");//电票清算方式
//                        xmlWriter.writeElementCDATA("BkAcctNum", "1");//账号数量
//                        xmlWriter.writeStartElement("BkAcctQuery_GRP");
//                        xmlWriter.writeElementCDATA("BkEcdQueryAcct", query.detail.actNum);//账号数量
//                        xmlWriter.writeEndElement();
//                        xmlWriter.writeEndDocument();
//
//                        String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
//
//                        if (tmpStrRet[0].length() == 0) {
//                            StringBuilder msg = new StringBuilder();
//                            XmlTextReader tmpBkReader = getBankInfo(tmpStrRet[1], msg);
//                            if (tmpBkReader != null) {
//                                String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                                String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                                String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                                if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                                    while (tmpBkReader.read("/Transaction/Transaction_Body/response/Bkydjgcx_GRP")) {
//                                        String memo = tmpBkReader.readedXElement.getSingleText("BkDetail2");
//                                        String billNo = tmpBkReader.readedXElement.getSingleText("BkListNo1");
//                                        if (StringHelper.hasAnyChar(memo) && memo.contains(query.detail.reqSeqID) && query.detail.billNo.equals(billNo)) {
//                                            detail.respCode = "0";
//                                            detail.respInfo = tmpBkReader.readedXElement.getSingleText("BkSumry");
//                                            detail.billState = tmpBkReader.readedXElement.getSingleText("BkFlag1");
//                                            detail.transState = tmpBkReader.readedXElement.getSingleText("BkFlag2");
//                                            detail.payInfoCode = detail.transState;
//                                            break;
//                                        }
//                                    }
//                                } else {
//                                    detail.respCode = "-1";
//                                    detail.respInfo = xln_status + xln_resp_code + xln_resp_desc;
//                                }
//                            } else {
//                                detail.respCode = "-1";
//                                detail.respInfo = msg.toString();
//                            }
//                        } else {
//                            detail.respCode = "-1";
//                            detail.respInfo = tmpStrRet[1];
//                        }
//                    } else {
//                        detail.respCode = "-1";
//                        detail.respInfo = "签到失败";
//                    }
//                } else {
//                    detail.respCode = "-1";
//                    detail.respInfo = "下载银行pub密钥失败";
//                }
//            } else {
//                detail.respCode = "-1";
//                detail.respInfo = "下载银行3des密钥失败";
//            }
//            retAts.writeDetail(detail);
//        } catch (Exception e) {
//            e.printStackTrace();
//            WriteBankLogLn("查询异常");
//        }
//    }
//
//    /**
//     * 过滤返回不匹配的应答信息
//     *
//     * @param busiType 1-出票 2-承兑 3-收票 4-背书转让 5-质押 6-解质押 7-出票保证 8-承兑保证 9-背书保证 10-贴现 11-回购式贴现赎回 12-提示付款 13-追索 14-同意清偿
//     * @param bktype2
//     * @param billType 1 银承 2 商承
//     * @return
//     * @throws Exception
//     */
//    protected boolean checkBkType(int busiType, String queryType, String bktype2, String billType) throws Exception {
//        boolean flag = false;
//        switch (busiType) {
//            case 2:
//                if ("4".equals(bktype2)) {
//                    flag = true;
//                }
//                break;
//            case 3:
//                if ("0".equals(bktype2)) {
//                    flag = true;
//                }
//                break;
//            case 4:
//                if ("5".equals(bktype2)) {
//                    flag = true;
//                }
//                break;
//            case 5:
//                if ("9".equals(bktype2) && "2".equals(billType)) {
//                    flag = true;
//                }
//                break;
//            case 6:
//                if ("10".equals(bktype2)) {
//                    flag = true;
//                }
//                break;
//            case 7:
//                if ("1".equals(bktype2)) {
//                    flag = true;
//                }
//                break;
//            case 8:
//                if ("2".equals(bktype2)) {
//                    flag = true;
//                }
//                break;
//            case 9:
//                if ("3".equals(bktype2)) {
//                    flag = true;
//                }
//                break;
//            case 11:
//                if ("11".equals(bktype2)) {
//                    flag = true;
//                }
//                break;
//            case 12:
//                if ("6".equals(bktype2)) {
//                    flag = true;
//                }
//                break;
////            case 13:if("7".equals(bktype2)){flag=true;} break;
//            case 14:
//                if ("8".equals(bktype2) && "2".equals(queryType)) {
//                    flag = true;
//                } else if ("7".equals(bktype2) && "1".equals(queryType)) {
//                    flag = true;
//                }
//                break;
//            default:
//                flag = false;
//        }
//        return flag;
//    }
//}
